package org.nobject.common.code.parser;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.nobject.common.file.FileUtils;

//import com.sun.source.tree.ClassTree;
//import com.sun.source.tree.MethodTree;
//import com.sun.source.util.TreeScanner;
//import com.sun.tools.javac.file.JavacFileManager;
//import com.sun.tools.javac.parser.Parser;
//import com.sun.tools.javac.parser.ParserFactory;
//import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
//import com.sun.tools.javac.tree.JCTree.JCImport;
//import com.sun.tools.javac.util.Context;

public class JDKParser {
	
      
//    //扫描方法时，把方法名加入到一个list中  
//    static class MethodScanner extends TreeScanner<List<String>, List<String>> {
//    	
//        /* (non-Javadoc)
//		 * @see com.sun.source.util.TreeScanner#visitClass(com.sun.source.tree.ClassTree, java.lang.Object)
//		 */
//		@Override
//		public List<String> visitClass(ClassTree arg0, List<String> arg1) {
//			// TODO Auto-generated method stub
//			return super.visitClass(arg0, arg1);
//		}
//
//		@Override  
//        public List<String> visitMethod(MethodTree node, List<String> p) {
//            System.out.println("------------------------------------->");
//            System.out.println(node.getName());
//            System.out.println(node.getBody());
//            return p;  
//        }  
//    }  
//  
//    public static void main(String[] args) throws IOException {
//    	
//    	String file="D:/WOR_HOME/ECLIPSE_WORKSPACE/common/trunk/src/org/nobject/common/android/AndroidUtils.java";
//    	
//    	Context context = new Context();  
//		JavacFileManager.preRegister(context);  
//		ParserFactory factory = ParserFactory.instance(context);
//		
//		Parser parser = factory.newParser(FileUtils.read2String(file), true, false, true);  
//		JCCompilationUnit unit =  parser.parseCompilationUnit();
//		
//		List<JCImport> imports=unit.getImports();
//		for(JCImport jcImport:imports){
//			System.out.println("IMPORT:"+jcImport.type.toString());
//		}
//		
////		MethodScanner scanner = new MethodScanner();  
////		List<String> methods=scanner.visitCompilationUnit(unit, new ArrayList<String>());  
////		
////		
////        for (String method : methods) {  
////            System.out.println(method);  
////        }  
//    }  
}
